package com.bridgeintelligent.tag.customer.track;

import com.bridgeintelligent.tag.utils.DateHelper;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.Map;

@Data
@ApiModel(value = "客群追踪配置信息实体")
@Accessors(chain = true)
public class TrackInfo implements Serializable {

    @ApiModelProperty("主键")
    private String id;

    @ApiModelProperty("客群Id")
    private String customerId;

    @ApiModelProperty("客群名称")
    private String customerName;

    @ApiModelProperty("筛选条件sql")
    private String customerSql;

    @ApiModelProperty("索引ID")
    private String indexId;

    @ApiModelProperty("动静态标志 fase:动态/true:静态")
    private String timeType;

    @ApiModelProperty("追踪开始时间")
    private String trackStartTime;

    @ApiModelProperty("追踪结束时间")
    private String trackEndTime;

    @ApiModelProperty("是否追踪客群人数 0:否/1：是")
    private String isTrackNum;

    @ApiModelProperty("追踪周期 d:每天/w:每周/m:每月")
    private String trackCycle;

    @ApiModelProperty("追踪标签集")
    private String trackDims;

    @ApiModelProperty("监测更新时间")
    private String trackUpdateTime;

    @ApiModelProperty("创建时间")
    private String createTime;

    @ApiModelProperty("创建者Id")
    private String createId;

    @ApiModelProperty("创建时间")
    private String updateTime;

    @ApiModelProperty("删除标志")
    private String isDel;

    @ApiModelProperty("标签映射关系")
    private Map<String,DimModel> dimMap;

    //处理监测状态
    @ApiModelProperty("监测状态 0:未开始监测/1:监测中/2:停止监测")
    public String getTrackStatus(){
        String current = DateHelper.currentDateTime(DateHelper.PATTERN_DATE_1);
        if (StringUtils.compare(current, trackStartTime) < 0){
            return "0";
        }else if (StringUtils.compare(current, trackEndTime) > 0){
            return "2";
        }else{
            return "1";
        }
    }



}
